<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE html>
<html>
<head>
	<title>登录界面</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<!-- 引入bootstrap -->
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
	<!-- 引入JQuery  bootstrap.js-->
	<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/jquery.validate.min.js"></script>
	<script type="text/javascript">
		<!--注册判断-->
		$(function(){
			$("#username1").blur(function () {
				var name=$("#username1").val();
				$.ajax({
					url:"${pageContext.request.contextPath}/user/selectName",
					type:"POST",
					data:{
						"username":name
					},
					dataType:"json",
					success:function (resp) {
						if(resp.type=="success"){
							$("#msg").html("用户名未被注册，可以使用");
							$("#msg").css("color","green");
							$('#regist').removeAttr("disabled");
						}else{
							$("#msg").html("用户名已被注册，请重新填写！");
							$("#msg").css("color","red");
							$('#regist').attr("disabled",true);
						}
					},
					error:function () {
						alert("查询失败")
					}
				})

			})
			$("#repassword").blur(function () {
				$("#checkpassword").empty();
				if($("#repassword").val()!=$("#registpassword").val()){
					$("#repassword").after("<span id='checkpassword' style='color:red'>两次输入的密码不一致</span>");
				}
			});
		})


		$(document).ready(function () {
			var time =new Date();
			var day= ("0"+time.getDate()).slice(-2);
			var month=("0"+(time.getMonth()+1)).slice(-2);
			var today=time.getFullYear()+"-"+(month)+"-"+(day);
			$("#grade").val(today)
		})
	</script>
	<style type="text/css">
		body{
			background: url(${pageContext.request.contextPath}/images/14.jpg)no-repeat;
			background-size:100% 100%;
			background-attachment:fixed;
		}
		#login-box {
			padding: 35px;
			border-radius:15px;
			//background: #56666B;
			background:rgba(86,102,107,0.5) ;
			color: #fff;
		}
	</style>
</head>
<body>

<!--主界面-->
<div class="container" id="top" style="margin: 100px 50px 200px 180px;">
	<div class="row" style="margin-top: 100px;">
		<div class="col-md-4"></div>
		<div class="col-md-4" id="login-box">
			<fieldset style="width: auto; margin: 0px auto;">
				<legend align="center">
					<font style="font-size:24px" face="楷体" color="white">
						校园导览小程序管理系统
					</font>
				</legend>
				<font color="red">
					<%-- 提示信息--%>
					<span id="message">${msg}</span>
					<span id="message">${zcmsg}</span>
				</font>
				<!--from表单： 登陆 注册-->
				<form class="form-horizontal" role="form" action="${pageContext.request.contextPath}/login" id="form1" method="post" >
					<div class="form-group">
						<label for="username" class="col-sm-3 control-label">用户名</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" id="username" placeholder="请输入名字" name="username">
						</div>
					</div>
					<div class="form-group">
						<label for="password" class="col-sm-3 control-label">密码</label>
						<div class="col-sm-9">
							<input type="password" class="form-control" id="password" placeholder="请输入密码" name="password">
						</div>
					</div>

					<div class="form-group pull-right" style="margin-right: 50px;">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="button" class="btn btn-default btn-info" data-target="#register" data-toggle="modal">注册</button>
						</div>
					</div>
					<div class="form-group pull-right" style="margin-right: 50px;">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-default btn-info">登录</button>
						</div>
					</div>
			</form>
			</fieldset>
		</div>
		<div class="col-md-4"></div>
	</div>
</div>

<!-- 注册窗口 -->
<div id="register" class="modal fade" tabindex="-1">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-body">
				<button class="close" data-dismiss="modal">
					<span>&times;</span>
				</button>
			</div>
			<div class="modal-title">
				<h1 class="text-center">注册</h1>
			</div>
			<div class="modal-body">
				<form class="form-group" action="${pageContext.request.contextPath}/user/doRegist" method="post">
					<div class="form-group">
						<label for="username1">用户名</label>
						<input class="form-control" type="text"  placeholder="请输入用户名" name="username" id="username1" />
						<span id="msg">${msg}</span>
					</div>

					<div class="form-group">
						<label>密码</label>
						<input class="form-control" type="password" placeholder="请输入密码" name="password" id="registpassword">
					</div>

					<div class="form-group">
						<label>再次输入密码</label>
						<input class="form-control" type="password" placeholder="请再次输入密码" name="repassword" id="repassword" onblur="check()">
					</div>

					<div class="form-group">
						<label for="telnumber">手机号</label>
						<input class="form-control" type="text" placeholder="请输入手机号（选填）" name="telnumber" id="telnumber">
					</div>
					<input class="form-control" type="date" name="grade" id="grade" style="visibility: hidden">
					<div class="text-right">
						<button class="btn btn-primary" type="submit" id="regist" disabled="disabled">确定</button>
						<button class="btn btn-danger" data-dismiss="modal">取消</button>
					</div>
					<a href="" data-toggle="modal" data-dismiss="modal" data-target="#login">已有账号？点我登录</a>
				</form>
			</div>
		</div>
	</div>
</div>
</body>
</html>